<template>
  <div>
    <h3>order/list</h3>
    <p>{{time}}</p>
    <router-link to="/dashboard">
      <button>dashboard</button>
    </router-link>
    <el-table :data="tableData">
      <el-table-column type="index" label="序号"></el-table-column>
      <el-table-column prop="age" label="年龄"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="id" label="id"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button @click="jumpDetail(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
import request from '@/api/index'
export default {
  name: 'order-list',
  meta: {
    title: '订单列表'
  },
  data () {
    return {
      time: '',
      tableData: []
    }
  },
  created () {
    this.time = (new Date()).toString()
    this.getData()
  },
  methods: {
    async getData () {
      let data = await request('index')
      this.tableData = data.list
    },
    jumpDetail (item) {
      this.$router.push({
        path: '/order/detail',
        query: {
          ...item
        },
        meta: {
          title: `详情${item.name}`
        }
      })
    }
  }
}
</script>
